package com.aaa.system.controller.api;

import com.aaa.entity.Menu;
import com.aaa.security.annotation.MyLog;
import com.aaa.system.service.MenuService;
import com.aaa.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author JYH
 * @version 1.0
 * @date 2023/2/27 11:35
 */
@Api(value = "/system/api/menu", tags = {"api菜单控制"})
@RestController
@RequestMapping("/system/api/menu")
public class ApiMenuController {
    @Autowired
    private MenuService menuService;

    /**
     * 根据id查询左侧菜单
     * @return
     */
//    @MyLog(title="查询左侧菜单")
    @ApiOperation(value = ")", notes = "@MyLog(title=", httpMethod = "GET")
    @GetMapping("/findAllMenu")
    public Result findAllMenu(){
       return menuService.findAllMenu();
    }

    /**
     * 添加菜单
     * @param menu
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Menu", name = "menu", value = "", required = true)
    })
    @ApiOperation(value = "添加菜单", notes = "添加菜单", httpMethod = "POST")
    @MyLog(title="添加菜单")
    @PostMapping("/addMenu")
    public Result addMenu(@RequestBody Menu menu){
       return menuService.addMenu(menu);
    }

    /**
     * 删除菜单
     * @param menuId
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "menuId", value = "", required = true)
    })
    @ApiOperation(value = "删除菜单", notes = "删除菜单", httpMethod = "DELETE")
    @MyLog(title="删除菜单")
    @DeleteMapping("/deleteMenu")
    public Result delete(Integer menuId){
        return menuService.deleteMenu(menuId);
    }

    /**
     * @author JYH
     * @date 2023/3/3 11:42
     * @description - 更新菜单
     * @param menu
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Menu", name = "menu", value = "", required = true)
    })
    @ApiOperation(value = "- 更新菜单", notes = "- 更新菜单", httpMethod = "POST")
    @MyLog(title="更新菜单")
    @PostMapping("/updateMenu")
    public Result update(@RequestBody Menu menu){
        return menuService.updateMenu(menu);
    }

    /**
     * 查询全部菜单
     * @return
     */
    @ApiOperation(value = "查询全部菜单", notes = "查询全部菜单", httpMethod = "GET")
    @MyLog(title = "查询全部菜单")
    @GetMapping("/selectAll")
    public Result selectAll(){
        return menuService.selectAll();
    }


}
